﻿using System;
using SlamCms.Common;

namespace SlamCms.DomainEvents
{
	internal class ActionDomainEventHandler<T> : IDomainEventHandler<T> where T : IDomainEvent
	{
		private readonly Action<EventContext<T>> _handler;

		public ActionDomainEventHandler(Action<EventContext<T>> handler)
		{
			Ensure.ArgumentNotNull(handler, "handler");

			_handler = handler;
		}

		public void Handle(EventContext<T> eventContext)
		{
			_handler(eventContext);
		}
	}
}
